import { Typography } from 'antd'
import StepList from './StepList.tsx'

const { Paragraph } = Typography

const getStepValue = (row, stepdata) => {
  const findIndex = stepdata.findIndex((item) => item.label === row?.stage)
  if (findIndex > 0) {
    return findIndex + 1
  } else {
    return 0
  }
}

const ellipsis = {
  showTitle: true
}

const orderIndex = (count: number) => ({
  title: '序号',
  key: '_index',
  width: 100,
  render: (_, __, index: number) => index + 1 + count
})

export const drugColumnTemp = (handleDetail: (row: any, b: boolean) => void, count: number) => [
  orderIndex(count),
  {
    title: '药品名称',
    key: 'drugStdName',
    dataIndex: 'drugStdName',
    render: (value: string) => (
      <Paragraph ellipsis={{ tooltip: value }}>
        <span style={{ color: '#0779ff', cursor: 'pointer' }} onClick={() => handleDetail(row, true)}>
          {value}
        </span>
      </Paragraph>
    )
  },
  {
    title: '阶段开始时间',
    key: 'stageStartDate',
    dataIndex: 'stageStartDate',
    ellipsis
  },
  {
    title: '适应症',
    key: 'indicationInfoStr',
    dataIndex: 'indicationInfoStr',
    render: (value: string) => (
      <Paragraph ellipsis={{ tooltip: value }}>
        <span>{value || '--'}</span>
      </Paragraph>
    )
  },
  {
    title: '最新进展',
    key: '最新进展',
    width: 320,
    render: (_, row: any) => <StepList stepValue={getStepValue(row, drugtepDataTemp)} data={drugtepDataTemp} />
  }
]
export const genericsColumnTemp = (handleDetail: (row: any, b: boolean) => void, count: number) => [
  orderIndex(count),
  {
    title: '药品名称',
    key: 'drugStdName',
    dataIndex: 'drugStdName',
    render: (value: string, row: any) => (
      <Paragraph ellipsis={{ tooltip: value }}>
        <span style={{ color: '#0779ff', cursor: 'pointer' }} onClick={() => handleDetail(row, true)}>
          {value}
        </span>
      </Paragraph>
    )
  },
  {
    title: '阶段开始时间',
    key: 'stageStartDate',
    dataIndex: 'stageStartDate',
    ellipsis
  },
  {
    title: '适应症',
    key: 'indicationInfoStr',
    dataIndex: 'indicationInfoStr',
    render: (value: string) => (
      <Paragraph ellipsis={{ tooltip: value }}>
        <span>{value || '--'}</span>
      </Paragraph>
    )
  },
  {
    title: '最新进展',
    key: '最新进展',
    width: 250,
    render: (_, row: any) => <StepList stepValue={getStepValue(row, genericsStepDataTemp)} data={genericsStepDataTemp} />
  }
]
export const instrumentColumnTemp = (handleDetail: (row: any, b: boolean) => void, count: number) => [
  orderIndex(count),
  {
    title: '产品名称',
    key: 'deviceName',
    dataIndex: 'deviceName',
    render: (value: string, row: any) => (
      <Paragraph ellipsis={{ tooltip: value }}>
        <span style={{ color: '#0779ff', cursor: 'pointer' }} onClick={() => handleDetail(row, true)}>
          {value}
        </span>
      </Paragraph>
    )
  },
  {
    title: '注册编号',
    key: 'regNo',
    dataIndex: 'regNo',
    ellipsis
  },
  {
    title: '器械类别',
    key: 'productCategory',
    dataIndex: 'productCategory',
    ellipsis
  },
  {
    title: '批准日期',
    key: 'aprvDate',
    dataIndex: 'aprvDate',
    ellipsis
  },
  {
    title: '首次获批年份',
    key: 'firstAprvYear',
    dataIndex: 'firstAprvYear',
    ellipsis
  },
  {
    title: '有效期至',
    key: 'endDate',
    dataIndex: 'endDate',
    ellipsis
  }
]
export const serviceColumnTemp = (count: number) => [
  orderIndex(count),
  {
    title: '类型',
    dataIndex: 'productServe',
    key: 'productServe',
    ellipsis
  },
  {
    title: '产品名称',
    dataIndex: 'productName',
    key: 'productName',
    ellipsis
  },
  {
    title: '规格',
    dataIndex: 'specModel',
    key: 'specModel',
    ellipsis
  }
]
// 卡片的 列表
export const drugtepDataTemp = [
  {
    label: '临床申请',
    value: 0
  },
  {
    label: 'I期临床',
    value: 0
  },
  {
    label: 'II期临床',
    value: 0
  },
  {
    label: 'III期临床',
    value: 0
  },
  {
    label: '上市申请',
    value: 0
  },
  {
    label: '获批上市',
    value: 0
  }
]
export const genericsStepDataTemp = [
  {
    label: '临床申请',
    value: 0
  },
  {
    label: '生物等效性试验',
    value: 0
  },
  {
    label: '上市申请',
    value: 0
  },
  {
    label: '获批上市',
    value: 0
  }
]
export const instrumentStepDataTemp = [
  {
    label: '获批上市',
    value: 0
  },
  {
    label: '一类器械',
    value: 0
  },
  {
    label: '二类器械',
    value: 0
  },
  {
    label: '三类器械',
    value: 0
  }
]

// 详情弹窗，
//药品三个阶段 ->受理，实验，上市

export const drugDetailAcceptance = [
  { label: '受理号', key: 'regNo' },
  { label: '药品名称', key: 'trialState' },
  { label: '药品类型', key: 'indication' },
  { label: '申请类型', key: 'drugType' },
  { label: '企业名称', key: 'sponsorName' },
  { label: '承办日期', key: 'firstAnnounceDate' },
  { label: '受理状态', key: 'trialPurpose' },
  { label: '受理状态开始时间', key: 'trialType' }
]
export const drugDetailExperiments = [
  { label: '登记号', key: 'regNo' },
  { label: '临床试验状态', key: 'trialState' },
  { label: '适应症', key: 'indication' },
  { label: '药物类型', key: 'drugType' },
  { label: '申办者名称', key: 'sponsorName' },
  { label: '经费类型', key: 'firstAnnounceDate' },
  { label: '实验目的', key: 'trialPurpose', colSpan: 2 },
  { label: '试验分类', key: 'trialType' },
  { label: '试验分期', key: 'trialStageModify' },
  { label: '首次公式日期', key: 'trialStageModify', colSpan: 2 }
]
export const drugDetailVolumeUp = [
  { label: '批准文号', key: 'regNo' },
  { label: '英文名称', key: 'trialState' },
  { label: '商品名', key: 'indication' },
  { label: '剂型', key: 'drugType' },
  { label: '规格', key: 'sponsorName' },
  { label: '生产单位', key: 'firstAnnounceDate' },
  { label: '生产地址', key: 'trialPurpose' },
  { label: '药品类型', key: 'trialType' },
  { label: '批准日期', key: 'trialStageModify' },
  { label: '药品本位码', key: 'trialStageModify' }
]
// 器械

export const instrumentDetail = [
  { label: '注册证编物', key: 'regNo' },
  { label: '器械类别', key: 'trialState' },
  { label: '注册人名称', key: 'indication' },
  { label: '注册人住所', key: 'indication' },
  { label: '生产地址', key: 'drugType' },
  { label: '规格型号', key: 'sponsorName' },
  { label: '适用范围', key: 'firstAnnounceDate' },
  { label: '药品类型', key: 'trialPurpose' },
  { label: '发证机关', key: 'trialType' },
  { label: '批准日期', key: 'trialStageModify' },
  { label: '有效期至', key: 'trialStageModify' },
  { label: '产品标准', key: 'trialStageModify' },
  { label: '变更日期', key: 'trialStageModify' },
  { label: '变更情况', key: 'trialStageModify' }
]
